<?php
/**
 * @fileName:CarBuilder.php
 * @project:basic_knowledge
 * @author : 吐火青蛙
 * @user : 吐火青蛙
 * @date : 2020/4/11
 *
 */

namespace miaosang\basicknowledge\design\builder;

use miaosang\basicknowledge\design\builder\BuilderInterface;
use miaosang\basicknowledge\design\builder\parts\Car;
use miaosang\basicknowledge\design\builder\parts\Vehicle;
use miaosang\basicknowledge\design\builder\parts\Wheel;
use miaosang\basicknowledge\design\builder\parts\Engine;
use miaosang\basicknowledge\design\builder\parts\Door;
class CarBuilder implements BuilderInterface
{

    private $car;
    public function createVehicle()
    {
        $this->car = new Car();
    }

    public function addWheel()
    {
        $this->car->setPart('wheelLF', new Wheel());
        $this->car->setPart('wheelRF', new Wheel());
        $this->car->setPart('wheelLR', new Wheel());
        $this->car->setPart('wheelRR', new Wheel());
    }

    public function addEngine()
    {
        $this->car->setPart('engine', new Engine());
    }

    public function addDoors()
    {
        $this->car->setParts('rightDoor',new Door());
        $this->car->setParts('leftDoor',new Door());
        $this->car->setParts('trunkLid',new Door());
    }

    public function getVehicle(): Vehicle
    {
       return  $this->car;
    }
}
